-
Notifications
You must be signed in to change notification settings - Fork 163
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix behavior when provided a malformed parameters file #556
Conversation
The function assumes that the structure has already been initialized, so it should be the callers responsibility to finalize it. Otherwise, this may lead to a double free as reported in #553. Signed-off-by: Jacob Perron <jacob@openrobotics.org>
This restores behavior that was lost when the '__params:=' syntax was deprecated in #495. An extra guard was also added when finalizing the parameters struct. Signed-off-by: Jacob Perron <jacob@openrobotics.org>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've got one suggestion for a comment improvement. The code looks good to me otherwise.
Can you add a test that tickles this problem?
rcl/src/rcl/arguments.c
Outdated
// If we return RCL_RET_ERROR then the argument contained the prefix '__params:=', | ||
// but the parameter file may be malformed or does not exist. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd suggest something like:
// If _rcl_parse_param_file_rule() returned RCL_RET_ERROR, then the argument contained the '__params:=' prefix,
// but parsing of the parameter file failed. Get out early here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Refactored: 0937963
Signed-off-by: Jacob Perron <jacob@openrobotics.org>
Signed-off-by: Jacob Perron <jacob@openrobotics.org>
@clalancette I've added a test that fails without this fix. PTAL. 98433bc |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good overall, thanks for taking care @jacobperron !
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good with green CI.
Also warn about deprecated usage, even if there is an error parsing parameters file. Signed-off-by: Jacob Perron <jacob@openrobotics.org>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! And test failures on MacOS seem unrelated.
@jacobperron I may be misunderstanding this, but I only see this commit on the Eloquent branch, not the master branch. If that is the case, we need to port it over to the master branch as well. |
This commit was only intended for the Eloquent branch. The bug was introduced when the old ROS CLI arguments were deprecated (see #553 (comment)). Since the deprecated syntax has since been removed on master, there is nothing to fix. |
Ah! I forgot about that, I was just noticing commits only on this branch. Thanks for the reminder. |
Fixes #553.
The function assumes that the structure has already been initialized, so it should be the callers
responsibility to finalize it. Otherwise, this may lead to a double free as reported in SIGABRT parsing yaml config file (double free detected) #553.
This restores behavior that was lost when the '__params:=' syntax was deprecated in Promote special CLI rules to flags #495.